<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录界面</title>
</head>
<body>


<form action="" method="">
    用户名:<input type="text" name="userName" id="userName"/><br/>
    密码：<input type="password" name="password" id="password"/><br/>
    <input type="button" id="btn1" value="登录" />
</form>



</body>
<script src="js/jquery-1.8.3.min.js"></script>
<script>
    $(function () {
        $("#btn1").click(function () {
            let userName = $("#userName").val();
            let password = $("#password").val();
            $.ajax({
                url:"/user/login",
                data:'{"userName":"'+userName+'","password":"'+password+'"}',
                type:"POST",
                dataType:"json",
                contentType:"application/json",
                success:function (data) {
                    if (data.flag == true){
                        location.href="list.html";
                    }else{
                        alert(data.message);
                    }
                }
            })
        })
    })
</script>

</html>